//
//  MessageListView.swift
//  GreenDeal
//
//  Created by Moennig Q on 24/2/2023.
//

import UIKit

class MessageListView: GreenNaviBarView {
    
    let searchTextfield = DIYTextField()
    let tableView: TableView = {
        let view = TableView.init(frame: .zero, style: .plain)
        view.backgroundColor = .white
        view.separatorStyle = UITableViewCell.SeparatorStyle.none
        view.estimatedRowHeight = 200
        view.rowHeight = UITableView.automaticDimension
        view.estimatedSectionHeaderHeight = 0
        view.estimatedSectionFooterHeight = 0
        view.showsVerticalScrollIndicator = false
        view.backgroundColor = .white
        view.register(MessageTableViewCell.self, forCellReuseIdentifier: MessageTableViewCell.reuseCellIdentifier)
        return view
    }()
    let allReadBtn = LayoutButton(.left,at: 10)
    override func setUpView() {
        //
        let contentView = UIView()
        contentView.backgroundColor = .white
        contentView.drawCorner(byRoundingCorners: [.topLeft,.topRight])
        self.addSubview(contentView)
        contentView.snp.makeConstraints { make in
            make.top.equalTo(self.topBackView.snp.bottom).offset(-20)
            make.left.right.bottom.equalToSuperview()
        }
        //searchTextfield
        searchTextfield.placeholder = R.string.localizable.search()
        searchTextfield.showRightImageView("edit_address_search_icon")
        contentView.addSubview(searchTextfield)
        searchTextfield.snp.makeConstraints { make in
            make.top.equalTo(20)
            make.left.equalTo(16)
            make.right.equalTo(-16)
            make.height.equalTo(DIYTextField.height)
        }
        //All read btn
        allReadBtn.backgroundColor = UIColor(hexStr: "#F5F5F5")
        allReadBtn.setBtnInfo("All Read",hexStr: "#292D32", textFont: R.font.interMedium(size: 15), imageName: "message_all_read_icon") 
        contentView.addSubview(allReadBtn)
        allReadBtn.snp.makeConstraints { make in
            make.bottom.equalToSuperview()
            make.left.right.equalToSuperview()
            make.height.equalTo(70)
        }
        //table view
        contentView.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.top.equalTo(searchTextfield.snp.bottom)
            make.left.right.equalToSuperview()
            make.bottom.equalTo(allReadBtn.snp.top)
        }
    }
}
